<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('鸡出库列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>

                        <li>
                            出库类型：<select name="outputType" th:with="type=${@dict.getType('outputType')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}" th:selected="*{dict.flag}"></option>
                        </select>
                        </li>
                        <li class="select-time">
                            <label>出库时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>

                        <li>
                            出库经手人：<input type="text" name="outputUser"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:ncOutputChicken:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:ncOutputChicken:remove')}]];
    var prefix = ctx + "system/ncOutputChicken";

    $(function () {
        //出库类型
        var outputType = [[${@dict.getType('outputType')}]];
        //鸡状态
        var chickenStatus = [[${@dict.getType('chickenStatus')}]];
        //宰杀后母鸡标准
        var isHealthy = [[${@dict.getType('isHealthy')}]];

        //初始化下面的table
        var options = {
            url: prefix + "/list?outputStatus=3",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export?outputStatus=3",
            modalName: "鸡出库",
            showExport: false,
            sortName: 'outputTime',
            sortOrder: 'desc',
            showFooter: true,
            columns: [
                {
                    field: 'outputId',
                    title: '入库id',
                    visible: false
                },
                {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    },
                    footerFormatter: function () {
                        return '汇总'
                    }
                },
                {
                    field: 'outputTime',
                    title: '出库日期',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'requestAmount',
                    title: '需求数量（只）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.requestAmount;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputAmount',
                    title: '供应数量（只）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.outputAmount;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputAmountBig',
                    title: '供应大鸡数量（只）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.outputAmountBig;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputAmountLittle',
                    title: '供应小鸡数量（只）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.outputAmountLittle;
                        });
                        return count;

                    }
                },
                {
                    field: 'outputType',
                    title: '出库类型',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(outputType, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'catchTime',
                    title: '抓鸡时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'chickenStatus',
                    title: '母鸡状态',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(chickenStatus, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'killTime',
                    title: '宰杀时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'isHealthy',
                    title: '宰杀后成品母鸡标准',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(isHealthy, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'butcher',
                    title: '宰杀人员',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'receiveTime',
                    title: '菜房接收时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'receiver',
                    title: '菜房接收人员',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'outputUser',
                    title: '出库经手人',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.outputId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.outputId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

    });

    function reload() {
        window.location.reload()
    }

    setTitle("所有出库", true)
</script>
</body>
</html>